#ifndef  SPARSEMATRIX_H
#define  SPARSEMATRIX_H
#include "MatrixObject.h"
#include <vector>
#include <algorithm>
#include <functional>

class SparseMatrix
{
public:
	SparseMatrix(int rows,long long cols);
	~SparseMatrix(void);
	inline bool setElement(int x,long long y,double value)
	{
		if(x>=ROWS || y>=COLS)
		{
			return false;
		}
		SM_pos[0].push_back(x);
		SM_pos[1].push_back(y);
		SM_val.push_back(value);
		return true;
	}

	const inline int Size() const{return SM_val.size();}
	inline int getX (int index){return SM_pos[0][index];}
	inline long long getY (int index){return SM_pos[1][index];}
	inline double getVal(int index){return SM_val[index];}

	void Output() const;

//SparseMatrix operator= (const SparseMatrix& rhs)
//{
//	SM_pos[0]=rhs.SM_pos[0];
//	SM_pos[1]=rhs.SM_pos[1];
//	SM_val=rhs.SM_val;
//	ROWS = rhs.ROWS;
//	COLS = rhs.COLS;
//	return *this;
//}

	MatrixObject s_n(const MatrixObject& A,const MatrixObject& B);
	void  WeightedElementwiseProduct(const MatrixObject& A,const MatrixObject& B,const MatrixObject& C,SparseMatrix &result);

//private:
	//double* array;
	long long ROWS,COLS;
    //vector<double *> SM;
	vector<long long> SM_pos[2];
	vector<double> SM_val;
};

#endif